package jsmc.android.object;

import jsmc.opendata.nantes.util.NeoLog;
import android.content.Intent;
import android.net.Uri;

public class NeoDialog {
	
	private String title=null;
	private String message=null;

	private DialogButton PositiveButton = null;
	private DialogButton NegativeButton = null;
	
	public NeoDialog(String title,String message) {
		this.title    = title;
		this.message  = message;
	}

	public NeoDialog setPositiveButton(String lib,String StrType,String StrVal,String StrFinish){
		
		PositiveButton = SetButton(lib,StrType,StrVal,StrFinish);
		return this;
		
	}
	
	public NeoDialog setNegativeButton(String lib,String StrType,String StrVal,String StrFinish){
		
		NegativeButton = SetButton(lib,StrType,StrVal,StrFinish);
		return this;
		
	}
	
	public String getTitle(){
		
		return title;
		
	}
	
	public String getMessage(){
		
		return message;
		
	}
	
	public DialogButton getPositiveButton(){
		
		return PositiveButton;
		
	}
	
	public DialogButton getNegativeButton(){
		
		return NegativeButton;
		
	}
	
	private DialogButton SetButton(String lib,String StrType,String StrVal,String StrFinish){
		
		NeoLog.v("LB NeoDialog","SetButton: "+lib+","+StrType+","+StrVal+","+StrFinish);
		
		Intent intent = null;
		boolean finish = true;
		
		finish = (StrFinish.equals("0")) ? false : true;
		DialogButton button = new DialogButton(lib, finish);
		
		if(StrType.equals("uri")){
			
			intent = new Intent(Intent.ACTION_VIEW, Uri.parse(StrVal));
			button.SetIntent(intent);
			
			NeoLog.v("LB NeoDialog","SetIntent: Intent.ACTION_VIEW, uri="+StrVal);
			
		} else if(StrType.equals("view")){
			
			intent = new Intent(StrVal);
			button.SetIntent(intent);
			
			NeoLog.v("LB NeoDialog","SetIntent: "+StrVal);
			
		}  else {
		
			NeoLog.v("LB NeoDialog","StrType unknow: "+StrType);
			
		} 

		return button;
		
	}
}
